home *** CD-ROM | disk | FTP | other *** search
- On Error Resume Next
-
- Const inBYTE = 1
- Const inKILO = 1024 ' 2^10
- Const inMEGA = 1048576 ' 2^20
- Const inGIGA = 1073741824 ' 2^30
- Const inTERA = 1099511627776 ' 2^40
- Const inPETA = 1.12589990684262E+15 ' 2^50
- Const inEXA = 1.15292150460685E+18 ' 2^60
- Const inZETTA = 1.18059162071741E+21 ' 2^70
- Const inYOTTA = 1.20892581961463E+24 ' 2^80
-
-
- Set objWshShell = CreateObject("WScript.Shell")
- strDesktop = objWshShell.SpecialFolders("Desktop")
- fSaveName = strDesktop & "\dossiers.htm"
- fCalcPath = InputBox("Quel est le chemin d'accΦs au dossier α analyser ?","Taille d'un dossier")
- If fCalcPath = "" Then Wscript.Quit
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set FileTxt = objFSO.CreateTextFile(fSaveName, True)
- Set Folder = objFSO.GetFolder(fCalcPath)
-
- FileTxt.WriteLine "<html><body><table border=1 cellpadding=2 cellspacing=0><th>Dossiers</th><th>Taille dossiers</th><th>Taille dossiers et sous-dossiers</th>"
-
-
- Set rootFolder = objFSO.GetFolder(Folder)
- For Each rootSubFolder in rootFolder.Subfolders
- Set colFiles = rootFolder.Files
-
-
- For Each objFile in colFiles
- tSize = objFile.Size + tSize
- Next
-
- tfSize = rootSubFolder.Size + tfSize
- Next
- If tSize < inKILO Then
- fSize = (tSize/inBYTE)
- tSize = FormatNumber(fSize,,,,0) & " octets"
- ElseIf tSize < inMEGA Then
- fSize = (tSize/inKILO)
- tSize = FormatNumber(fSize,,,,0) & " Ko"
- ElseIf tSize < inGIGA Then
- fSize = (tSize/inMEGA)
- tSize = FormatNumber(fSize,,,,0) & " Mo"
- ElseIf tSize < inTERA Then
- fSize = (tSize/inGIGA)
- tSize = "<b style=color:#FF0000>" & FormatNumber(fSize,,,,0) & " Go</b>"
- End If
- If tfSize < inKILO Then
- ffSize = (tfSize/inBYTE)
- tfSize = FormatNumber(ffSize,,,,0) & " octets"
- ElseIf tfSize < inMEGA Then
- ffSize = (tfSize/inKILO)
- tfSize = FormatNumber(ffSize,,,,0) & " Ko"
- ElseIf tfSize < inGIGA Then
- ffSize = (tfSize/inMEGA)
- tfSize = FormatNumber(ffSize,,,,0) & " Mo"
- ElseIf tfSize < inTERA Then
- ffSize = (tfSize/inGIGA)
- tfSize = "<b style=color:#FF0000>" & FormatNumber(ffSize,,,,0) & " Go</b>"
- End If
- FileTxt.WriteLine "<tr bgcolor=#FFFFCC><td><a href='" & Folder.Path & "'>" & Folder.Path & "</a></td><td align=right>" & tSize & "</td><td align=right>" & tfSize & "</td></tr>"
- tsize = 0
- Set rootFolder = Nothing
-
-
- For Each SubFolder In Folder.Subfolders
- Set currentFolder = objFSO.GetFolder(SubFolder)
- Set colFiles = currentFolder.Files
- '** get subfolder files
- For Each objFile in colFiles
- tSize = objFile.Size + tSize
- Next
- If tSize < inKILO Then
- fSize = (tSize/inBYTE)
- tSize = FormatNumber(fSize,,,,0) & " octets"
- ElseIf tSize < inMEGA Then
- fSize = (tSize/inKILO)
- tSize = FormatNumber(fSize,,,,0) & " Ko"
- ElseIf tSize < inGIGA Then
- fSize = (tSize/inMEGA)
- tSize = FormatNumber(fSize,,,,0) & " Mo"
- ElseIf tSize < inTERA Then
- fSize = (tSize/inGIGA)
- tSize = "<b style=color:#FF0000>" & FormatNumber(fSize,,,,0) & " Go</b>"
- End If
- If (SubFolder.Size < inKILO) Then
- ffSize = (SubFolder.Size/inBYTE)
- tfSize = FormatNumber(ffSize,,,,0) & " octets"
- ElseIf (SubFolder.Size < inMEGA) Then
- ffSize = (SubFolder.Size/inKILO)
- tfSize = FormatNumber(ffSize,,,,0) & " Ko"
- ElseIf (SubFolder.Size < inGIGA) Then
- ffSize = (SubFolder.Size/inMEGA)
- tfSize = FormatNumber(ffSize,,,,0) & " Mo"
- ElseIf (SubFolder.Size < inTERA) Then
- ffSize = (SubFolder.Size/inGIGA)
- tfSize = "<b style=color:#FF0000>" & FormatNumber(ffSize,,,,0) & " Go</b>"
- End If
-
- FileTxt.WriteLine "<tr bgcolor=#FFFFCC><td><a href='" & SubFolder.Path & "'>" & SubFolder.Path & "</a></td><td align=right>" & tSize & "</td><td align=right>" & tfSize & "</td></tr>"
- tsize = 0
- funcGetSubFolders SubFolder.Path
- Next
-
-
- FileTxt.WriteLine "</table></body></html>"
- FileTxt.Close
- MsgBox "Fin de l'analyse. Ouvrez le fichier " & fSaveName,64,"Taille des dossiers"
- Set objFSO = Nothing
- Set FileTxt = Nothing
- Set Folder = Nothing
- Wscript.Quit
-
-
- Sub funcGetSubFolders(sPath)
- Set objFldr = objFSO.GetFolder(sPath)
- For Each SubFolder In objFldr.SubFolders
- Set currentFolder = objFSO.GetFolder(SubFolder)
- Set colFiles = currentFolder.Files
-
- For Each objFile in colFiles
- tSize = objFile.Size + tSize
- Next
-
- If tSize < inKILO Then
- fSize = (tSize/inBYTE)
- tSize = FormatNumber(fSize,,,,0) & " bytes"
- ElseIf tSize < inMEGA Then
- fSize = (tSize/inKILO)
- tSize = FormatNumber(fSize,,,,0) & " kb"
- ElseIf tSize < inGIGA Then
- fSize = (tSize/inMEGA)
- tSize = FormatNumber(fSize,,,,0) & " MB"
- ElseIf tSize < inTERA Then
- fSize = (tSize/inGIGA)
- tSize = "<b style=color:#FF0000>" & FormatNumber(fSize,,,,0) & " GB</b>"
- End If
-
- If (SubFolder.Size < inKILO) Then
- ffSize = (SubFolder.Size/inBYTE)
- tfSize = FormatNumber(ffSize,,,,0) & " bytes"
- ElseIf (SubFolder.Size < inMEGA) Then
- ffSize = (SubFolder.Size/inKILO)
- tfSize = FormatNumber(ffSize,,,,0) & " kb"
- ElseIf (SubFolder.Size < inGIGA) Then
- ffSize = (SubFolder.Size/inMEGA)
- tfSize = FormatNumber(ffSize,,,,0) & " MB"
- ElseIf (SubFolder.Size < inTERA) Then
- ffSize = (SubFolder.Size/inGIGA)
- tfSize = "<b style=color:#FF0000>" & FormatNumber(ffSize,,,,0) & " GB</b>"
- End If
-
- FileTxt.WriteLine "<tr><td><a href='" & SubFolder.Path & "'>" & SubFolder.Path & "</a></td><td align=right>" & tSize & "</td><td align=right>" & tfSize & "</td></tr>"
- tsize = 0
- funcGetSubFolders SubFolder.Path
- Next
- Set objFldr = Nothing
- End Sub
-